package com.llamarun;

import java.util.ArrayList;
import java.util.Random;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.View;

public abstract class GameObject {
	private Bitmap sprite;
	private int x;
	private int y;
	protected GameView view;
	
	public void update(int gameTime)
	{
		return;
	}
	
	
	public boolean offScreen(View view)
	{
		if(x<-sprite.getWidth()/2 || x>view.getWidth()||y>view.getHeight()*2 || y<-view.getHeight()*2)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	public Bitmap getBitmap()
	{
		return sprite;
	}
	public void setBitmap(Bitmap bitmap)
	{
		this.sprite = bitmap;
	}
	public int getX()
	{
		return x;
	}
	public void setX(int x)
	{
		this.x = x;
	}
	public int getY()
	{
		return y;
	}
	public void setY(int y)
	{
		this.y = y;
	}
	
	public boolean collision(GameObject enemy)
	{
		Rect enemyRect = new Rect(
				this.getX()-this.sprite.getWidth()/3, 
				this.getY()-this.sprite.getHeight()/3,
				this.getX()+this.sprite.getWidth()/3,
				this.getY()+this.sprite.getHeight()/3);
		
		Rect thisRect = new Rect(
				enemy.getX()-enemy.sprite.getWidth()/3,
				enemy.getY()-enemy.sprite.getHeight()/3,
				enemy.getX()+enemy.sprite.getWidth()/3,
				enemy.getY()+enemy.sprite.getHeight()/3
				);
		
		if (Rect.intersects(thisRect, enemyRect))
		{
			return true;
		}
		return false;
	}
	
	public boolean canIDie()
	{
		return false;
	}
	
	static public int probabilityScore()
	{
		return 1;
	}
	
	public void draw(Canvas canvas) {
		canvas.drawBitmap(sprite, x - (sprite.getWidth() / 2), y - (sprite.getHeight() / 2), null);
	}


	public void collideWithLlama(Llama llama) {
		// TODO Auto-generated method stub
		
	}


	public GameObject collideWithEnemy(ArrayList<GameObject> gameObjects) {
		// TODO Auto-generated method stub
		return null;
	}
}
